#ifndef ADDATTENTIONSDIALOG_H
#define ADDATTENTIONSDIALOG_H

#include "globaltype.h"
#include <QDialog>
#include <QPointer>
#include <QStringList>

QT_BEGIN_NAMESPACE
class QStandardItemModel;
QT_END_NAMESPACE

namespace yc {
class Downloader;
class LoadingFrame;
struct Presenter;
}

namespace Ui {
class AddAttentionsDialog;
}

class LiveRecorder;

class AddAttentionsDialog : public QDialog
{
    Q_OBJECT

public:
    enum { CHECK_STATE_COLUMN, NAME_COLUMN, ID_COLUMN };
    enum { AVATAR_ROLE = DataRole::OTHER_ROLE };

    explicit AddAttentionsDialog(LiveRecorder* recorder, QWidget* parent = nullptr);
    ~AddAttentionsDialog();

private:
    QStringList getIds() const;
    void searchPresenters();
    void searchMore();
    void addItem(const yc::Presenter& presenter);
    void downloadAvatar(const QString& url);
    bool canAdd() const;
    void updateUiStatus();
    void setUiEnabled(bool enabled);
    void updateAllCheckState();
    void showLoading();
    void hideLoading();
    void addAttentions();

    Ui::AddAttentionsDialog* ui;

    LiveRecorder* recorder_;
    QStandardItemModel* model_;
    QString keyword_;
    int search_count_ = 0;
    QPointer<yc::Downloader> downloader_;
    yc::LoadingFrame* loading_frame_ = nullptr;
};

#endif // ADDATTENTIONSDIALOG_H
